<template>
  <el-dialog title="打印" :visible.sync="openOne" width="800px" append-to-body :before-close="close">
    <div v-if="list" id="printMe" class="main1">
      <div class="title">
        <p class="zi1">南京综保区跨境电子商务发展有限公司</p>
      </div>
      <div style="float:left;width:555px;">
        <p class="title2">INBOUND TALLY SHEET</p>
      </div>
      <div class="area">
        <div class="column">
          <p class="zi1">工作号:</p>
          <p class="zi2">{{ list.job_number }}</p>
        </div>
        <div class="column column2">
          <p class="zi1">委托日期:</p>
          <p class="zi2">{{ list.entrust_date }}</p>
        </div>
        <div class="column">
          <p class="zi1">内部类型:</p>
          <p class="zi2">{{ list.inside_type_name }}</p>
        </div>
        <div class="column column2">
          <p class="zi1">主单号:</p>
          <p class="zi2">{{ list.main_doc_no }}</p>
        </div>
        <div class="column">
          <p class="zi1">分单号:</p>
          <p class="zi2">{{ list.sub_order_No }}</p>
        </div>
        <div class="column column2">
          <p class="zi1">体积:</p>
          <p class="zi2">{{ list.volume }}</p>
        </div>
      </div>
      <hr style="float:left;width:555px;margin-top:5px;">
      <div v-if="list" class="form">
<!--        <div class="name">费用信息</div>-->
        <div class="area">
          <div class="column">
            <p class="zi1">费用代码:</p>
            <p class="zi2">{{ list.expense_code }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">费用名称:</p>
            <p class="zi2">{{ list.expense_name }}</p>
          </div>
          <div class="column">
            <p class="zi1">费用类型:</p>
            <p class="zi2">{{ list.expenses_type }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">结算代码:</p>
            <p class="zi2">{{ list.settlement_code }}</p>
          </div>
          <div class="column">
            <p class="zi1">结算名称:</p>
            <p class="zi2">{{ list.settlement_name }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">单价:</p>
            <p class="zi2">{{ list.unit_price }}</p>
          </div>
          <div class="column">
            <p class="zi1">数量:</p>
            <p class="zi2">{{ list.quantity }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">金额:</p>
            <p class="zi2">{{ list.money }}</p>
          </div>
          <div class="column">
            <p class="zi1">汇率:</p>
            <p class="zi2">{{ list.exchange_rate }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">币种:</p>
            <p class="zi2">{{ list.currency }}</p>
          </div>
          <div class="column">
            <p class="zi1">费用标题:</p>
            <p class="zi2">{{ list.cost_title }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">账单号:</p>
            <p class="zi2">{{ list.account_number }}</p>
          </div>
          <div class="column">
            <p class="zi1">发票号:</p>
            <p class="zi2">{{ list.invoice_no }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">开票日期:</p>
            <p class="zi2">{{ list.invoicing_date }}</p>
          </div>
          <div class="column">
            <p class="zi1">本位币金额:</p>
            <p class="zi2">{{ list.base_currency_money }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">税金:</p>
            <p class="zi2">{{ list.taxes }}</p>
          </div>
          <div class="column">
            <p class="zi1">支票号:</p>
            <p class="zi2">{{ list.cheque }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">请款单号:</p>
            <p class="zi2">{{ list.request_funds }}</p>
          </div>
          <div class="column">
            <p class="zi1">备注:</p>
            <p class="zi2">{{ list.remarks }}</p>
          </div>
        </div>
      </div>
      <hr style="float:left;width:555px;margin-top:5px;">
      <div class="tail">
        <div class="nr1">
          <p class="zi1">创建人:</p>
          <p class="zi2">{{ list.creator }}</p>
        </div>
        <div class="nr1">
          <p class="zi1">创建时间:</p>
          <p class="zi2">{{ list.created_at }}</p>
        </div>
      </div>
    </div>
    <el-row style="top: 30px;margin-bottom: 30px;text-align:center;">
      <el-col :span="24">
        <el-button v-print="'#printMe'" type="primary" size="medium">打印</el-button>
      </el-col>
    </el-row>
  </el-dialog>
</template>
<script>
import { expensePrint } from '@/api/settlement'
export default {
  name: 'Print',
  props: {
    openOne: {
      type: Boolean
    },
    id: {
      type: Number
    }
  },
  data() {
    return {
      list: []
    }
  },
  watch: {
    'openOne': function(newValue, oldValue) {
      if (newValue === true) {
        this.printList()
      }
    }
  },
  methods: {
    printList() {
      const that = this
      const data = {
        id: this.id
      }
      expensePrint(data).then(response => {
        console.log(response.data)
        if (response.code === 10000) {
          that.list = response.data
        }
      })
    },
    close() {
      this.$emit('update:openOne', false)
    }
  }
}
</script>
<style lang="scss" scoped>
img {
    width: 100%;
    float: left;
}

p {
    padding: 0;
    margin: 0;
    font-family: 宋体
}

div {
    font-family: 宋体;
}

.main1 {
    width: 555px;
    background: #fff;
    padding: 0px 20px;
    margin:auto;
}

.title {
    float: left;
    width: 555px;
    border-bottom: 2px solid #000;
    padding: 10px 0px;
}

.title .logo {
    float: left;
    width: 116px;
    height: 30px;
}

.title .zi1 {
    float:right;
    line-height: 30px;
    font-size: 18px;
    color: #000;
}
.title .zi2 {
    float:right;
    line-height: 30px;
    font-size: 14px;
    color: #999;
    width:555px;
    text-align:right;
}

.title2 {
    float: left;
    line-height: 40px;
    font-size: 18px;
    color: #970000;
}

.title2-1 {
    float:right;
    height: 40px;
    width:200px;
}

.area {
    float: left;
    width: 555px;
}

.area p {
    font-size: 11px;
    line-height: 24px;
}

.area .column {
    float: left;
    width: 272.5px;
    margin-right: 10px;
    margin-bottom: 5px;
}

.area .column .img1{float:left;width:200px;height:40px;margin-left:10px;}

.area .column2 {
    margin-right: 0;
}

.area .zi1 {
    float: left;
    border-bottom: 1px solid #fff;
    width: 100px;
}

.area .zi2 {
    float: left;
    //border-bottom: 1px solid #000;
    width: 160.5px;
    margin-left: 10px;
}

.form {
    float: left;
    width: 555px;
    margin-top: 10px;
}

.form .name {
    float: left;
    width: 555px;
    font-size: 14px;
    line-height:30px;
}

table,
td,
th {
    padding: 3px;
    border: 1px solid #aaa;
    text-align: center;
    font-size: 12px;
    line-height: 18px;
}

th {
    font-weight: bold;
}

.separate {
    border-collapse: separate;
}

.collapsed {
    border-collapse: collapse;
    width: 555px;
}

.tail {
    float: left;
    width: 555px;
    margin-top: 5px;
    margin-bottom: 20px;
}

.tail .nr1 {
    float: left;
    width: 277.5px;
    font-size: 10px;
    line-height: 18px;
}

.tail .nr1 p {
    float: left;
}

.tail .nr1 .zi2 {
    margin-left: 5px;
}
</style>

